package com.t194.util;


//import com.t194.pojo.Staff;
//import com.t194.service.staffservice;
//import org.apache.shiro.authc.AuthenticationException;
//import org.apache.shiro.authc.AuthenticationInfo;
//import org.apache.shiro.authc.AuthenticationToken;
//import org.apache.shiro.authc.SimpleAuthenticationInfo;
//import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
//import org.apache.shiro.authz.AuthorizationInfo;
//import org.apache.shiro.realm.AuthorizingRealm;
//import org.apache.shiro.subject.PrincipalCollection;
//import org.apache.shiro.util.ByteSource;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;

//@Component("dbRealm")
//public class DbRealm extends AuthorizingRealm {
//    /*@Resource
//    权限
//    private PermissionService permissionService;
//    */
//    @Resource
////    private staffservice staffservice;
//
//
//    private HashedCredentialsMatcher credentialsMatcher;
//
//    @Resource
//    public void setCredentialsMatcher(HashedCredentialsMatcher credentialsMatcher) {
//        super.setCredentialsMatcher(credentialsMatcher);
//    }
//
////    @Override
////    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
////        User user = (User)principalCollection.getPrimaryPrincipal();
////        List<String> list =  permissionService.findPermRole(user.getUserCode());
////        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
////        info.addStringPermissions(list);
////        return info;
////    }
//
//    @Override
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//        String userCode = token.getPrincipal().toString();
//        Staff staff = staffservice.login(userCode);
//        if(staff==null){
//            return null;
//        }
//        SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(staff,staff.getPwd(), ByteSource.Util.bytes(staff.getSalt()),super.getName());
//        return info;
//    }
//
//    @Override
//    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
//        return null;
//    }
//}
